package www.com.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import www.com.common.ListResult;
import www.com.entity.Film;
import www.com.service.FilmService;

import javax.validation.Valid;
import java.util.Map;

import  www.com.utils.JwtUtil;

@RestController
@RequestMapping("/films")
public class FilmController {

    @Autowired
    private FilmService filmService;

    @GetMapping("")
    public ListResult<Film> getFilmList(@Valid @ModelAttribute Film film, @RequestParam(defaultValue = "5") Integer pageSize, @RequestParam(defaultValue = "1") Integer currentPage) {
        return filmService.getAllFilmList(film, pageSize, currentPage);
    }

    @PostMapping("/createFilm")
    public Object createFilm(@RequestBody Film film) {
        return filmService.createFilm(film);
    }

    @PostMapping("/deleteFilm")
    public Object deleteFilm(@RequestBody Film film) {
        return filmService.deleteFilm(film.getId());
    }
    @PostMapping("/updateFilm")
    public Object updateFilm(@RequestBody Film film) {
        return filmService.updateFilm(film);
    }
}
